﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <title></title>
    <link rel="stylesheet" type="text/css" href="/ViewMob/css/default.css">
    <link href="/ViewMob/css/reset.css" rel="stylesheet" type="text/css">
    <link href="/ViewMob/js/layer/need/layer.css" rel="stylesheet" />
    <script src="/ViewMob/js/layer/layer.m.js"></script>
    <script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
    <script src="/ViewMob/js/avalon.mobile.js"></script>
    <script src="/ViewMob/js/ComFunJS.js"></script>
    <script src="/ViewMob/js/zepto.md5.js"></script>
    <style>
        select {
            border: none;
            width: 100%;
            font-size: 1.5rem;
            height: 100%;
            background-color: #efefb4;
            padding-left: .5REM;
        }

        input {
            border: none;
            width: 100%;
            font-size: 1.5rem;
            height: 100%;
            background-color: #efefb4 !important;
            padding-left: .5REM;
        }

        body {
            background: url(../images/teacher.gif);
            background-repeat: no-repeat;
            background-size: 100% 100%;
            background-attachment: fixed;
            background-position: top left;
            overflow: hidden;
        }
    </style>
    <script>
        //
        var model = avalon.define({
            $id: "Login",
            username: "",
            Pasword: "",
            userdata: {},
            openid: "",
            initxt: function () {
                var code = ComFunJS.getQueryString("code");
                if (code) {
                    $.getJSON('/API/VIEWAPI.ashx?Action=Commanage_GETWXUSERINFO', { code: code }, function (resultData) {
                        if (resultData.ErrorMsg == "") {
                            if (resultData.Result1 == "N") {
                                model.openid = resultData.Result.openid;
                                $("#login").show();
                            } else {
                                ComFunJS.setCookie("openid", resultData.Result.openid);
                                ComFunJS.setCookie("userdata", JSON.stringify(resultData.Result2));
                                location.href = "UI_Index.html";

                            }
                        }
                    })
                } else {
                    location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx90be690cf4947d59&redirect_uri=http://xyxt.wxit.edu.cn/ViewMob/UI/UI_Login.html&response_type=code&scope=snsapi_userinfo&state=STATSE#wechat_redirect";
                }
            },
            LoginUser: function (dom) {
                var msg = "";
                if ($.trim(model.username) == "") {
                    msg = "请输入用户名";
                    ComFunJS.winwarning(msg);
                    return;
                }

                if ($.trim(model.Pasword) == "") {
                    msg = "请输入密码";
                    ComFunJS.winwarning(msg);
                    return;
                }
                $.post("/API/VIEWAPI.ashx?Action=COM_XYLOGIN&r=" + Math.random(), { "UserName": model.username, password: model.Pasword, openid: model.openid }, function (data) {
                    if (data.ErrorMsg == "") {
                        ComFunJS.setCookie('userdata', JSON.stringify(data.Result));
                        model.userdata = data.Result;
                        location.href = "UI_Index.html";
                    }
                    else {
                        ComFunJS.winwarning(data.ErrorMsg);

                    }
                })
            }
        })
        avalon.ready(function () {
            ComFunJS.setCookie('userdata', "");
            model.initxt();
        })
    </script>
</head>
<body style="display: table; width: 100%" ms-controller="Login">

    <div class="form-box" id="login" style="display: none">
        <div class="logo-teacher tc" style="font-size: 40px; color: #1C8DF4">
            无锡职业技术学院
        </div>
        <div class="logo-teacher tc" style="font-size: 16px;">
            校友管理系统
        </div>
        <div class="input-panel" style="margin-top: 100px;">
            <input type="tel" placeholder="手机号" ms-duplex="username">
        </div>
        <div class="input-panel">
            <input type="password" placeholder="密码" ms-duplex="Pasword">
        </div>
        <div class="input-panel-btn">
            <button ms-click="LoginUser(this)">
                登录
            </button>
            <div class="login-zc">没有账号？<a href="UI_Regit.html">去注册</a></div>

        </div>
    </div>
</body>
</html>
